package com.irdstudio.tdp.console.service.impl;

import java.util.*;
import com.alibaba.fastjson.JSON;
import com.irdstudio.sdk.beans.core.constant.BaseConstant;
import com.irdstudio.sdk.beans.core.util.KeyUtil;
import com.irdstudio.sdk.beans.core.util.TimeUtil;
import com.irdstudio.sdk.beans.core.util.UUIDUtil;
import com.irdstudio.sdp.dmcenter.common.util.TablePropertyUtil;
import com.irdstudio.sdp.dmcenter.service.facade.ModelTableFieldService;
import com.irdstudio.sdp.dmcenter.service.facade.ModelTableInfoService;
import com.irdstudio.sdp.dmcenter.service.facade.ProjectTmPackageService;
import com.irdstudio.sdp.dmcenter.service.vo.ModelTableFieldVO;
import com.irdstudio.sdp.dmcenter.service.vo.ModelTableInfoVO;
import com.irdstudio.tdp.console.dao.IsrvCondInfoDao;
import com.irdstudio.tdp.console.dao.*;
import com.irdstudio.tdp.console.dao.domain.IsrvCondInfo;
import com.irdstudio.tdp.console.dao.domain.IsrvInoutInfo;
import com.irdstudio.tdp.console.dao.domain.OsrvLinkedInfo;
import com.irdstudio.tdp.console.dao.domain.OsrvNodeInfo;
import com.irdstudio.tdp.console.service.vo.ExcelExp;
import com.irdstudio.tdp.console.service.vo.OsrvLinkedInfoVO;
import com.irdstudio.tdp.console.service.vo.OsrvNodeInfoVO;
import com.irdstudio.tdp.console.dao.domain.*;
import com.irdstudio.tdp.console.service.vo.*;
import com.irdstudio.tdp.console.utils.excel.ExcelUtil;
import com.irdstudio.sdk.beans.core.exception.BizException;
import com.irdstudio.sdk.beans.core.util.DateUtility;
import com.irdstudio.tdp.executor.core.plugin.gencode.AppModelInfoConstant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.irdstudio.tdp.console.service.facade.AppModelInfoService;
import com.irdstudio.tdp.console.dao.domain.AppModelInfo;
import com.irdstudio.tdp.console.service.vo.AppModelInfoVO;
import com.irdstudio.sdk.beans.core.base.FrameworkService;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>ServiceImpl: 应用模型信息				<p>
 * @author zjj
 * @date 2021-03-16
 */
@Service("appModelInfoServiceImpl")
public class AppModelInfoServiceImpl implements AppModelInfoService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(AppModelInfoServiceImpl.class);

	@Autowired
	private AppModelInfoDao appModelInfoDao;

	@Autowired
	private OsrvNodeInfoDao osrvNodeInfoDao;

	@Autowired
	private OsrvLinkedInfoDao osrvLinkedInfoDao;

	@Autowired
	private IsrvInoutInfoDao isrvInoutInfoDao;

	@Autowired
	private IsrvCondInfoDao isrvCondInfoDao;

	@Autowired
	@Qualifier("modelTableInfoService")
	private ModelTableInfoService modelTableInfoService;

	@Autowired
	@Qualifier("projectTmPackageService")
	private ProjectTmPackageService projectTmPackageService ;

	@Autowired
	@Qualifier("modelTableFieldService")
	private ModelTableFieldService modelTableFieldService;

	/**
	 * 新增操作
	 */
	public int insertAppModelInfo(AppModelInfoVO inAppModelInfoVo) {
		logger.debug("当前新增数据为:"+ inAppModelInfoVo.toString());
		int num = 0;
		try {
			AppModelInfo appModelInfo = new AppModelInfo();
			beanCopy(inAppModelInfoVo, appModelInfo);
			num = appModelInfoDao.insertAppModelInfo(appModelInfo);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	public int insertAppModelInfos(List<AppModelInfo> appModelInfos) {
		logger.debug("批量新增数据");
		int num = 0;
		try {
			num = appModelInfoDao.insertAppModelInfos(appModelInfos);
		}catch (Exception e){
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		return num;
	}

	/**
	 * 删除操作
	 */
	public int deleteByPk(AppModelInfoVO inAppModelInfoVo) {
		logger.debug("当前删除数据条件为:"+ inAppModelInfoVo);
		int num = 0;
		try {
			AppModelInfo appModelInfo = new AppModelInfo();
			beanCopy(inAppModelInfoVo, appModelInfo);
			num = appModelInfoDao.deleteByPk(appModelInfo);
			//删除服务登记信息
			if(num==1){
				IsrvInoutInfo isrvInoutInfo=new IsrvInoutInfo();
				isrvInoutInfo.setAppModelId(inAppModelInfoVo.getAppModelId());
				isrvInoutInfoDao.deleteByAppModelId(isrvInoutInfo);
			}
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inAppModelInfoVo +"删除的数据条数为"+ num);
		return num;
	}


	/**
	 * 更新操作
	 */
	public int updateByPk(AppModelInfoVO inAppModelInfoVo) {
		logger.debug("当前修改数据为:"+ inAppModelInfoVo.toString());
		int num = 0;
		try {
			AppModelInfo appModelInfo = new AppModelInfo();
			beanCopy(inAppModelInfoVo, appModelInfo);
			num = appModelInfoDao.updateByPk(appModelInfo);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inAppModelInfoVo +"修改的数据条数为"+ num);
		return num;
	}
	
	/**
	 * 查询操作
	 */
	public AppModelInfoVO queryByPk(AppModelInfoVO inAppModelInfoVo) {
		
		logger.debug("当前查询参数信息为:"+ inAppModelInfoVo);
		try {
			AppModelInfo queryAppModelInfo = new AppModelInfo();
			beanCopy(inAppModelInfoVo, queryAppModelInfo);
			AppModelInfo queryRslAppModelInfo = appModelInfoDao.queryByPk(queryAppModelInfo);
			if (Objects.nonNull(queryRslAppModelInfo)) {
				AppModelInfoVO outAppModelInfoVo = beanCopy(queryRslAppModelInfo, new AppModelInfoVO());
				logger.debug("当前查询结果为:"+ outAppModelInfoVo.toString());
				return outAppModelInfoVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


	/**
	 * 查询用户权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<AppModelInfoVO> queryAllOwner(AppModelInfoVO appModelInfoVo) {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		List<AppModelInfoVO> list = null;
		try {
			List<AppModelInfo> appModelInfos = appModelInfoDao.queryAllOwnerByPage(appModelInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ appModelInfos.size());
			pageSet(appModelInfos, appModelInfoVo);
			list = (List<AppModelInfoVO>) beansCopy(appModelInfos, AppModelInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;

	}

	/**
	 * 查询用户权限数据
	 * @param appModelInfoVo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<AppModelInfo2VO> queryAllOwner2(AppModelInfoVO appModelInfoVo) {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		List<AppModelInfo2VO> list = null;
		try {
			List<AppModelInfo2> appModelInfos = appModelInfoDao.queryAllOwnerByPage2(appModelInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ appModelInfos.size());
			pageSet(appModelInfos, appModelInfoVo);
			list = (List<AppModelInfo2VO>) beansCopy(appModelInfos, AppModelInfo2VO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	
	}


	/**
	 * 查询当前机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<AppModelInfoVO> queryAllCurrOrg(AppModelInfoVO appModelInfoVo) {

		logger.debug("当前查询本人所属机构数据信息的参数信息为:");
		List<AppModelInfo> appModelInfos = appModelInfoDao.queryAllCurrOrgByPage(appModelInfoVo);
		logger.debug("当前查询本人所属机构数据信息的结果集数量为:"+appModelInfos.size());
		List<AppModelInfoVO> list = null;
		try {
			pageSet(appModelInfos, appModelInfoVo);
			list = (List<AppModelInfoVO>) beansCopy(appModelInfos, AppModelInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构及下属机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<AppModelInfoVO> queryAllCurrDownOrg(AppModelInfoVO appModelInfoVo) {

		logger.debug("当前查询本人所属机构及以下数据信息的参数信息为:");
		List<AppModelInfo> appModelInfos = appModelInfoDao.queryAllCurrDownOrgByPage(appModelInfoVo);
		logger.debug("当前查询本人所属机构及以下数据信息的结果集数量为:"+ appModelInfos.size());
		List<AppModelInfoVO> list = null;
		try {
			pageSet(appModelInfos, appModelInfoVo);
			list = (List<AppModelInfoVO>) beansCopy(appModelInfos, AppModelInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}

	@Override
	public Map<String, Object> queryExternalServiceFlowChart(String appId, String appModelId) {
		logger.info("外部服务 流程数据查询 appId {} appModelId {}", appId, appModelId);

		AppModelInfo appModelInfo = new AppModelInfo();
		appModelInfo.setAppModelId(appModelId);
		try {
			appModelInfo = appModelInfoDao.queryByPk(appModelInfo);
		} catch (Exception e) {
			logger.error("查询服务信息异常 appId {} appModelId {}", appId, appModelId, e);
			throw new RuntimeException("查询服务信息异常", e);
		}
		if (appModelInfo == null) {
			return Collections.emptyMap();
		}
		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put(AppModelInfo.class.getSimpleName(), appModelInfo);

		OsrvNodeInfoVO paramNodeVO = new OsrvNodeInfoVO();
		paramNodeVO.setAppModelId(appModelId);
		// osrv_node_info
		List<OsrvNodeInfoVO> osrvNodeInfoVOList;
		try {
			List<OsrvNodeInfo> osrvNodeInfoList = osrvNodeInfoDao.queryAllOwnerByPage(paramNodeVO);
			osrvNodeInfoVOList = (List<OsrvNodeInfoVO>) beansCopy(osrvNodeInfoList, OsrvNodeInfoVO.class);
		} catch (Exception e) {
			logger.error("查询服务节点信息异常 appId {} appModelId {}", appId, appModelId, e);
			throw new RuntimeException("查询服务节点信息异常", e);
		}
		resultMap.put(OsrvNodeInfo.class.getSimpleName(), osrvNodeInfoVOList);
		// osrv_linked_info
		List<OsrvLinkedInfoVO> osrvLinkedInfoVOList;
		try {
			List<OsrvLinkedInfo> linkedList = osrvLinkedInfoDao.queryOsrvLinkedInfoVOListByAppModelId(appModelId);
			osrvLinkedInfoVOList = (List<OsrvLinkedInfoVO>) beansCopy(linkedList, OsrvLinkedInfoVO.class);
		} catch (Exception e) {
			logger.error("查询服务链接信息异常 appId {} appModelId {}", appId, appModelId, e);
			throw new RuntimeException("查询服务链接信息异常", e);
		}
		resultMap.put(OsrvLinkedInfo.class.getSimpleName(), osrvLinkedInfoVOList);

		return resultMap;
	}

	@Override
	public Boolean saveExternalServiceFlowChart(String appId, Map<String, Object> flowData) {
		logger.info("外部服务 保存流程数据 appId {} ", appId);
		List osrvNodeInfos = (List) flowData.get(OsrvNodeInfo.class.getSimpleName());
		List osrvLinkedInfos = (List) flowData.get(OsrvLinkedInfo.class.getSimpleName());

		if (CollectionUtils.isNotEmpty(osrvNodeInfos) ) {
			// 转换成 List of OsrvNodeInfoVO
			List<OsrvNodeInfo> osrvNodeInfoVOList = JSON.parseArray(JSON.toJSONString(osrvNodeInfos), OsrvNodeInfo.class);
			for (OsrvNodeInfo node : osrvNodeInfoVOList) {

				try {
					OsrvNodeInfo checkObj = osrvNodeInfoDao.queryByPk(node);
					if (checkObj != null) {
						osrvNodeInfoDao.updateByPk(node);
					} else {
						osrvNodeInfoDao.insertOsrvNodeInfo(node);
					}
				} catch (Exception e) {
					logger.error("", e);
					throw new RuntimeException(e.getMessage(), e);
				}

			}
		}
		if (CollectionUtils.isNotEmpty(osrvLinkedInfos) ) {
			// 转换成 List of OsrvLinkedInfoVO
			List<OsrvLinkedInfo> osrvNodeInfoVOList = JSON.parseArray(JSON.toJSONString(osrvLinkedInfos), OsrvLinkedInfo.class);
			for (OsrvLinkedInfo link : osrvNodeInfoVOList) {

				try {
					OsrvLinkedInfo checkObj = osrvLinkedInfoDao.queryByPk(link);
					if (checkObj != null) {
						osrvLinkedInfoDao.updateByPk(link);
					} else {
						osrvLinkedInfoDao.insertOsrvLinkedInfo(link);
					}
				} catch (Exception e) {
					logger.error("", e);
					throw new RuntimeException(e.getMessage(), e);
				}

			}
		}
		return true;
	}

	@Override
	public void generateExcelDocuments(String appId, HttpServletResponse response) throws BizException {
		//文件名时间戳
		String date = DateUtility.formatDateTime19To14(DateUtility.getCurrDateTime());
		String fileName = appId+date+".xls";
		List<ExcelExp> mysheet = new ArrayList<ExcelExp>();

		//服务基本信息
		List<String[]> dataset1 = new ArrayList<String[]>();//为了对应ExcelExp.java的参数要求
		String[] handers1 = {"服务名","服务描述"};
		ExcelExp e1 = new ExcelExp("服务基本信息", handers1, dataset1);

		//输入参数信息
		List<String[]> dataset2 = new ArrayList<String[]>();
		String[] handers2 = {"参数字段代码","参数字段类型","参数字段名称"};
		ExcelExp e2 = new ExcelExp("输入参数信息", handers2, dataset2);

		//输出参数信息
		List<String[]> dataset3 = new ArrayList<String[]>();
		String[] handers3 = {"参数字段代码","参数字段类型","参数字段名称"};
		ExcelExp e3 = new ExcelExp("输出参数信息", handers3, dataset3);

		mysheet.add(e1);
		mysheet.add(e2);
		mysheet.add(e3);
		ExcelUtil.exportManySheetExcel(fileName, mysheet,response); //生成sheet

	}

	@Override
	public Boolean initDataServiceModel(String appId, String projectId, AppModelInfoVO appModelInfo) {
		List<String> objectCodes = Arrays.asList(appModelInfo.getTableModelCode());

		List<ModelTableInfoVO> modelTableInfoVOs = getModelTableInfoVOList(projectId, objectCodes);

		List<AppModelInfo> appModelInfoVOs4Insert = new ArrayList<>();
		List<IsrvInoutInfo> isrvInoutInfoVOs4Insert = new ArrayList<>();
		List<IsrvCondInfo> isrvCondInfoVOList = new ArrayList<>();
		String time = TimeUtil.getCurrentDateTime();
		List<ModelTableFieldVO> modelTableFieldVOs = null;

		String[] appModelTypes = StringUtils.split(appModelInfo.getAppModelType(), ",");

		if (appModelTypes == null || appModelTypes.length == 0) {
			return true;
		}
		for (ModelTableInfoVO tableInfoVO : modelTableInfoVOs) {
			// 读取表字段信息，用于初始化开发模型
			modelTableFieldVOs = getModelTableFieldVOList(projectId, tableInfoVO);

			for (String modelTypeCode : appModelTypes) {

				AppModelInfoConstant.DataServiceModelEnum modelEnum = AppModelInfoConstant.DataServiceModelEnum.getModelByType(modelTypeCode);
				if (modelEnum == null) {
					continue;
				}
				AppModelInfo appModelInfoVo = new AppModelInfo();

				String tableModelId = TablePropertyUtil.columnName2JavaBeanMember(tableInfoVO.getObjectCode());
				String modelCode = tableModelId + modelEnum.getCode();
				appModelInfoVo.setAppId(appId);
				appModelInfoVo.setAppModelId(UUIDUtil.getUUID());//应用业务模型标识
				appModelInfoVo.setAppModelCode(modelCode);//应用业务模型代码
				appModelInfoVo.setAppModelName(tableInfoVO.getObjectName() + modelEnum.getName());//应用业务模型名称
				appModelInfoVo.setAppModelCatalog(AppModelInfoConstant.DATA_MODEL_CATALOG);//业务模型分类
				appModelInfoVo.setAppModelType(modelEnum.getType());//应用业务模型类型
				appModelInfoVo.setPackageId(appModelInfo.getPackageId());
				appModelInfoVo.setTableModelId(tableInfoVO.getObjectId());//表模型ID
				appModelInfoVo.setTableModelCode(tableInfoVO.getObjectCode());//表模型代码
				appModelInfoVo.setTableModelName(tableInfoVO.getObjectName());//表模型名称，中文名称
				appModelInfoVo.setCreateUser(AppModelInfoConstant.DEFAULT_USER_ID);//创建用户 TODO
				appModelInfoVo.setCreateTime(time);//创建时间
				//appModelInfoVo.setLastUpdateUser();//最后修改人
				//appModelInfoVo.setLastUpdateTime();//最后更新时间

				appModelInfoVOs4Insert.add(appModelInfoVo);

				for (ModelTableFieldVO fieldVO : modelTableFieldVOs) {
					//如果是删除模型时，只有主键字段需要插入数据

					IsrvInoutInfo appModelIn = new IsrvInoutInfo();
					appModelIn.setRecordKeyid(KeyUtil.createUUIDKey());//记录唯一编号（用于唯一标识一条记录）
					appModelIn.setAppModelId(appModelInfoVo.getAppModelId());//开发模型标识
					appModelIn.setParamFieldCode(fieldVO.getFieldCode());//参数代码
					appModelIn.setParamFieldName(fieldVO.getFieldName());//参数名称
					appModelIn.setParamFieldType(fieldVO.getFieldType());
					appModelIn.setIoType(AppModelInfoConstant.IO_TYPE.I.getCode());//io_type(I,输入O,输出)
					appModelIn.setMustNeed(BaseConstant.NO_N);//是否必需
					isrvInoutInfoVOs4Insert.add(appModelIn);

					// 数据查询模型：初始化表模型全部字段作为输入字段，初始化表模型全部字段作为输出字段。
					// 单条数据模型：初始化表模型全部字段作为输入字段，初始化表模型全部字段作为输出字段。
					if (AppModelInfoConstant.DataServiceModelEnum.QUERY == modelEnum || AppModelInfoConstant.DataServiceModelEnum.SINGLE == modelEnum) {
						IsrvInoutInfo appModelOut = new IsrvInoutInfo();
						appModelOut.setRecordKeyid(KeyUtil.createUUIDKey());//记录唯一编号（用于唯一标识一条记录）
						appModelOut.setAppModelId(appModelInfoVo.getAppModelId());//开发模型标识
						appModelOut.setParamFieldCode(fieldVO.getFieldCode());//参数代码
						appModelOut.setParamFieldName(fieldVO.getFieldName());//参数名称
						appModelOut.setParamFieldType(fieldVO.getFieldType());
						appModelOut.setIoType(AppModelInfoConstant.IO_TYPE.O.getCode());//io_type(I,输入O,输出)
						appModelOut.setMustNeed(BaseConstant.NO_N);//是否必需
						isrvInoutInfoVOs4Insert.add(appModelOut);
					}

					if (AppModelInfoConstant.DataServiceModelEnum.QUERY == modelEnum) {
						IsrvCondInfo condVO = new IsrvCondInfo();
						condVO.setAppModelId(appModelInfoVo.getAppModelId());
						condVO.setCondId(KeyUtil.createUUIDKey());
						condVO.setCondFieldCode(fieldVO.getFieldCode());
						condVO.setCondFieldName(fieldVO.getFieldName());
						condVO.setParamFieldCode(fieldVO.getFieldCode());
						condVO.setParamFieldName(fieldVO.getFieldName());
						condVO.setCondCompareSign("=");
						condVO.setCompareTargetType("2"); //输入参数
						condVO.setCondLogicRelation("and");
						isrvCondInfoVOList.add(condVO);
					}

					if ((AppModelInfoConstant.DataServiceModelEnum.ADD == modelEnum
							|| AppModelInfoConstant.DataServiceModelEnum.SINGLE == modelEnum
							|| AppModelInfoConstant.DataServiceModelEnum.UPDATE == modelEnum
							|| AppModelInfoConstant.DataServiceModelEnum.DELETE == modelEnum)
							&& BaseConstant.YES_Y.equals(fieldVO.getIsPk())) {
						// 初始化表模型主键字段作为修改条件
						IsrvCondInfo pkCond = new IsrvCondInfo();
						pkCond.setAppModelId(appModelInfoVo.getAppModelId());
						pkCond.setCondId(KeyUtil.createUUIDKey());
						pkCond.setCondFieldCode(fieldVO.getFieldCode());
						pkCond.setCondFieldName(fieldVO.getFieldName());
						pkCond.setParamFieldCode(fieldVO.getFieldCode());
						pkCond.setParamFieldName(fieldVO.getFieldName());
						pkCond.setCondCompareSign("=");
						pkCond.setCompareTargetType("2"); //输入参数
						pkCond.setCondLogicRelation("and");
						isrvCondInfoVOList.add(pkCond);
					}
				}

				if (AppModelInfoConstant.DataServiceModelEnum.ADD == modelEnum
						|| AppModelInfoConstant.DataServiceModelEnum.UPDATE == modelEnum
						|| AppModelInfoConstant.DataServiceModelEnum.DELETE == modelEnum) {
					// 增 删 改 输出 初始化一条记录，字段代码:cnt,字段名称：影响记录数，类型:整型
					IsrvInoutInfo appModelOut = new IsrvInoutInfo();
					appModelOut.setRecordKeyid(KeyUtil.createUUIDKey());//记录唯一编号（用于唯一标识一条记录）
					appModelOut.setAppModelId(appModelInfoVo.getAppModelId());//开发模型标识
					appModelOut.setParamFieldCode("cnt");//参数代码
					appModelOut.setParamFieldName("影响记录数");//参数名称
					appModelOut.setParamFieldType("int");
					appModelOut.setIoType(AppModelInfoConstant.IO_TYPE.O.getCode());//io_type(I,输入O,输出)
					appModelOut.setMustNeed(BaseConstant.NO_N);//是否必需
					isrvInoutInfoVOs4Insert.add(appModelOut);


				}
			}
		}

		// 批量插入
		appModelInfoDao.insertAppModelInfos(appModelInfoVOs4Insert);
		isrvInoutInfoDao.insertIsrvInoutInfos(isrvInoutInfoVOs4Insert);
		isrvCondInfoDao.insertIsrvCondInfos(isrvCondInfoVOList);

		return true;
	}



	List<ModelTableInfoVO> getModelTableInfoVOList(String projectId, List<String> objectCodes) {
		ModelTableInfoVO tableInfoParam = new ModelTableInfoVO();
		tableInfoParam.setProjectId(projectId);
		tableInfoParam.setObjectCodes(objectCodes);
		return modelTableInfoService.queryAllByTableInfo(tableInfoParam);
	}

	List<ModelTableFieldVO> getModelTableFieldVOList(String projectId, ModelTableInfoVO modelTableInfoVO) {
		// 模型字段集合
		ModelTableFieldVO fieldParam = new ModelTableFieldVO();
		fieldParam.setObjectId(modelTableInfoVO.getObjectId());
		return modelTableFieldService.queryModelTableField(fieldParam);
	}
}
